package com.saicmotor.core.common.utils

inline fun <T, R> T.takeIfWith(otherwise: R, predicate: (T) -> Boolean): R where T : R {
    return if (predicate(this)) otherwise else this
}

inline fun <T : CharSequence> T?.ifNullOrEmpty(defaultValue: () -> T): T {
    return if (isNullOrEmpty()) defaultValue() else this
}

fun <T> T?.isNull() = null === this

fun <T> T?.isNotNull() = !isNull()